<template>
    <view class="content">
        <view class="top">
            <view class="title">{{data.title}}</view>
            <view class="time">{{data.date}}</view>
        </view>
        <view class="box">
            <u-parse :html="data.details"></u-parse>
        </view>
        <view class="footer" v-if="type == 1 && data.status == 0" @click="toJoin">立即参与</view>
        <view class="footer footer2" v-if="type == 1 && data.status == 1" >已参与</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 0,
                id: '',
                data: {},
            };
        },
        onLoad(option) {
            if (option.id) {
                this.id = option.id
            }
            if (option.type) {
                this.type = option.type
            }
            this.getData()
        },
        methods: {
            toJoin() {
                this.$ajax('activity_join', {
                	user_token: this.$getSync('userToken'),
                    id: this.id,//活动id
                }).then(ret => {
                	if (ret.success == 1000) {
                		this.$toast('提交成功')
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.msg);
                	}
                });
            },
            
            getData() {
            	this.$ajax('activity_detail', {
            		user_token: this.$getSync('userToken'),
                    id: this.id,//活动id
            	}).then(ret => {
            		if (ret.success == 1000) {
            			this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #fff;
        border-top: 2rpx solid #eee;
    }
    .content{
        padding: 35rpx 25rpx;
    }
    .top{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 35rpx;
        border-bottom: 2rpx solid #eee;
    }
    .title{
        font-size: 36rpx;
        font-weight: bold;
        padding-bottom: 10rpx;
    }
    .time{
        font-size: 24rpx;
        color: #666666;
    }
    .box{
        padding: 40rpx 0 150rpx;
    }
    .footer{
        width: 710rpx;
        height: 87rpx;
        background-color: #fec427;
        border-radius: 10rpx;
        font-size: 30rpx;
        font-weight: bold;
        color: #000;
        line-height: 87rpx;
        text-align: center;
        position: fixed;
        left: 20rpx;
        bottom: 20rpx;
        z-index: 9;
    }
    .footer2{
        background-color: #c6c6c6;
    }

</style>
